<?

class Find extends CI_controller {



	function __construct()
	{
	parent::__construct();
	$this->is_logged_in();
	}



	function index()
	{
		$data['overskrift_left'] = "Søg";
		$data['overskrift_right'] = "og find";
		$data['underskrift_left'] = "";
		$data['underskrift_right'] = "";
        
		$data['request'] = $this->input->post('request');


        $this->load->model("soeg/soeg_model");

        $data['resultat'] = $this->soeg_model->soeg($data['request'],"element");
        

		$indhold_left[] = 'soeg/resultat';

		$indhold_right[] = 'forord/parfogul';
		
		$data['content_left'] = $indhold_left;
		$data['content_right'] = $indhold_right;
		$this->load->view('includes/templates/bogpaapult',$data); // 2 * $indhold

    }



	function is_logged_in()
	{
		
		$redirect = $this->session->set_userdata(current_url());
		

		// Definerer session med $is_logged_in
		$is_logged_in = $this->session->userdata('deltager');
		$is_ingame = $this->session->userdata('ingame');
		
		// 
		if(empty($is_logged_in) or empty($is_ingame))
		{
			// Viser header, tilskuer.php med besked om "at det ikke lykkedes at blive deltager" og footer 
		$this->session->unset_userdata('deltager');
		$this->session->unset_userdata('ingame');
		$this->session->sess_destroy();
		redirect('login');
		
		 		
		}
	}

}
